package com.springboot.controller;

import com.springboot.model.Employee;
import com.springboot.service.EmployeeService;
import com.springboot.util.TenantThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author: TongRui乀
 * @Date: 2019-11-15 15:54
 * @description：
 */
@RestController
@RequestMapping("employee")
public class EmployeeController {



    @Autowired
    private EmployeeService employeeService;


    @GetMapping("getEmployee")
    public List<Employee> getEmployee(){

        return  this.employeeService.getEmployee();
    }


    @PutMapping("create")
    public String create(String empName, String desc, Integer deptId){

        this.employeeService.createEmployee(empName, desc, deptId);

        return "SUCCESS";
    }

    @PostMapping("testTx")
    public String testTx(Integer isException){

        return this.employeeService.testTx(isException);
    }

}
